import Popup from './Popup.vue';
import Vue from 'vue';

// 获取Popup组件的构造函数
// 通过vue.extend()新建一个子类PopupConstructor
// Popup是对应的Popup的模板
const PopupConstructor = Vue.extend(Popup);

const serve = (popup)=>{ 
    // 创建Popup实例
    let popupInstance = new PopupConstructor();
    // 将组件挂载到指定的元素
    popupInstance.$mount(document.createElement('div'));
    // 将组件挂载的元素添加到body元素下
    document.body.appendChild(popupInstance.$el);

    popupInstance.popup = popup;
    
    Vue.nextTick(()=>{
        popupInstance.visible = true;
    })
}

export default serve;